home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13816 < prev    next >
Encoding:
Text File  |  1996-08-05  |  898 b   |  30 lines

  1. Newsgroups: comp.lang.c
  2. Path: netcom.com!russells
  3. From: russells@netcom.com (Russell Salsbury)
  4. Subject: Re: How to detect if a number has fractions
  5. Message-ID: <russellsDpMopI.Ks@netcom.com>
  6. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  7. References: <4kb1p8$gph@gate.compart.fi>
  8. Date: Wed, 10 Apr 1996 04:05:41 GMT
  9. Sender: russells@netcom10.netcom.com
  10.  
  11. joonas.kervinen@pcb.compart.fi (joonas kervinen) writes:
  12.  
  13. >Here's a small detail (not quite Win spesific, sorry!) that's bugging
  14. >me: How do I detect in Borland C (BCC4.5 or 5.0) whether a double
  15. >value has fractions. And I mean quickly, not using time consuming
  16. >floating point functions.
  17. >Please answer via e-mail.
  18.  
  19. Why not use floating point?
  20.  
  21. #include <math.h>
  22. int has_frac(double d)
  23. {
  24.     if (d - floor(d) != 0.0) return 1;
  25.     return 0;
  26. }
  27.  
  28. Who the !#$^% would want MSWINdows!?  Ewww.. cooties.
  29. Ryan    russells@netcom.com
  30.